import {
  request
} from './request'

// 获取商品列表
export const getWaresList = async function () {
  const waresListData = await request({
    url: '/user/wares/get_wares_list',
    method: 'GET'
  })
  return waresListData
}
// 根据分类获取商品列表
export const getBrandsWaresList = async function (brandsId) {
  const waresListData = await request({
    url: '/user/wares/get_brands_wares?brandsId=' + brandsId,
    method: 'GET'
  })
  return waresListData
}

// 获取全部分类
export const getBrandsList = async function () {
  const brandsListData = await request({
    url: '/user/wares/get_brands_list',
    method: 'GET'
  })
  return brandsListData
}

// 获取商品详情
export const getWaresDetail = async function (waresId) {
  const waresDetailData = await request({
    url: '/user/wares/get_wares_style/' + waresId,
    method: 'GET'
  })
  return waresDetailData
}

// 商品详情根据某个款式获取对应的红包套餐
export const getStyleCostDetail = async function (styleId) {
  const styleCostDetailData = await request({
    url: '/user/wares/get_style_cost',
    method: 'GET',
    data: {
      styleId: styleId
    }
  })
  return styleCostDetailData
}

// 用户登录
export const login = async function (query) {
  const loginData = await request({
    url: '/user/user/login',
    method: 'POST',
    data: query
  })
  return loginData
}

// 获取购物车列表
export const getCartList = async function () {
  const cartListData = await request({
    url: '/user/cart/get_cart',
    method: 'GET'
  })
  return cartListData
}

// 加入购物车
export const addCart = async function (query) {
  const addCartData = await request({
    url: '/user/cart/save_cart',
    method: 'POST',
    data: query
  })
  return addCartData
}

// 更新购物车数量
export const updateCartNumber= async function(query) {
  const updateCartNumberData = await request({
    url: '/user/cart/upd_number',
    method: 'POST',
    data: query
  })
  return updateCartNumberData
}

// 删除购物车
export const deleteCart = async function(query) {
  const deleteCartData = await request({
    url: '/user/cart/del_cart',
    method: 'POST',
    data: query
  })
  return deleteCartData
}

// 添加订单
export const addOrders = async function (query) {
  const addOrdersData = await request({
    url: '/user/orders/save_orders',
    method: 'POST',
    data: query
  })
  return addOrdersData
}

// 订单详情
export const getOrdersDetail = async function(query) {
  const ordersDetailData = await request({
    url: '/user/orders/get_orders',
    method: 'GET',
    data: query
  })
  return ordersDetailData
}

// 添加地址
export const saveAddress = async function(query) {
  const saveAddressData = await request({
    url: '/user/address/save_user_address',
    method: 'POST',
    data: query
  })
  return saveAddressData
}
// 地址列表
export const getAddressList = async function() {
  const getAddressListData = await request({
    url: '/address/get_user_address_list',
    method: 'GET'
  })
  return getAddressListData
}
// 编辑地址（数据回显）
export const getUpdateAddressInfo = async function(query) {
  const getUpdateAddressInfosData = await request({
    url: '/address/get_update_user_address',
    method: 'POST',
    data: query
  })
  return getUpdateAddressInfosData
}
// 编辑地址
export const updateAddress = async function(query) {
  const updateAddressData = await request({
    url: '/address/update_user_address',
    method: 'POST',
    data: query
  })
  return updateAddressData
}
// 删除地址
export const removeAddress = async function(query) {
  const removeAddressData = await request({
    url: '/address/remove_user_address',
    method: 'POST',
    data: query
  })
  return removeAddressData
}